<template>
  <div class="detailCss">
    <div class="topCss">
      <span>企业信息</span>
    </div>
    <div class="bodyCss">
      <el-form :model="form" ref="formRef" label-width="140px" :rules="rules" class="formCss">
        <template>
          <div class="approveCss">
            <div class="approveTitleCss">
              企业信息
            </div>
            <div class="companyInfoCss">
              <div class="companyInfoItemCss">
                <div style="flex:1;">企业名称</div>
                <div style="flex:1;">{{ currentRow.enterpriseName }}</div>
              </div>
              <div class="companyInfoItemCss">
                <div style="flex:1;">社会信用代码</div>
                <div style="flex:1;">{{ currentRow.creditCode }}</div>
              </div>
              <div class="companyInfoItemCss">
                <div style="flex:1;">详细地址</div>
                <div style="flex:1;">{{ currentRow.addr }}</div>
              </div>
              <div class="companyInfoItemCss">
                <div style="flex:1;">经营范围</div>
                <div style="flex:1;">{{ currentRow.businessScope }}</div>
              </div>
              <div class="companyInfoItemCss">
                <div style="flex:1;">企业类型</div>
                <div style="flex:1;">
                  <dict-tag
                    :options="dict.type.enterprise_info_type"
                    :value="currentRow.type"/>
                  </div>
              </div>
              <div class="companyInfoItemCss">
                <div style="flex:1;">类别</div>
                <div style="flex:1;">
                  <dict-tag
                    :options="dict.type.enterprise_category"
                    :value="currentRow.category"/>
                </div>
              </div>
            </div>

          </div>
        </template>
      </el-form>
    </div>
    <div class="footerBtnCss">
      <el-button @click="goBackClickBtn">返回</el-button>
      <el-button type="primary" @click="approveClickBtn('1')" :loading="approveLoading">审核成功</el-button>
      <el-button type="primary" @click="approveClickBtn('2')" :loading="approveLoading">审核失败</el-button>
    </div>
  </div>
</template>

<script>
import { submitEnterpriseAudit } from '@/api/zhangping/certificate'
import { getSelectOptionsFun, getCurrentDay } from '@/utils/business.js'
export default {
  dicts: ['enterprise_info_type','enterprise_category'],
  props:{
    currentRow:{
      type: Object,
      default:{},
    },
  },
  data(){
    return{
      detailPageStatusMap:{
        approve:{
        title:'审核'
      },},
      form:{},
      rules:{

      },
      tableData:[],
      approveLoading:false,
    }
  },
  mounted(){
    if( this.detailPageType === 'productDetail'){
      this.getList()
    }
  },
  methods:{
    getList(){
      for( let i=0;i<1;i++){
        const oneItem = {
          tData1: '【测试数据】消毒产品A',
          tData2: 'XXXXXX机构',
          tData3: '51594892196181',
          tData4: getCurrentDay(),
        }
        this.tableData.push(oneItem)
      }
    },
    init(row){
      this.form = {
        id:null,
        data11:null,
        data12:null,
        data13:null,
        data14:null,
      };
      this.resetForm("formRef")
      if( row ){
        this.form.id = row.id
      }
    },
    goBackClickBtn(){
      this.$emit('detailPageGoBack')
    },
    async approveClickBtn(stats){
      try {
        this.approveLoading = true
        const approvalStatusQueryMap = {
          pass: '1',fail:'2'
        }
        const query = {
          enterpriseId: this.currentRow.id,
          creditCode: this.currentRow.creditCode,
          stats: stats //string 审核状态 0 待审核, 1审核通过 2审核失败
        }
        const { code, msg } = await submitEnterpriseAudit(query)
        if( code === 200 ){
          this.$message({ message: msg, type: 'success' })
          this.goBackClickBtn()
        }
        this.approveLoading = false
      } catch (error) {
        console.log('error=>',error);
        this.approveLoading = false
      }
    },
  },
}
</script>

<style scoped lang="scss">
.detailCss{
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 23px 0;
  .topCss{
    height: 50px;
    font-weight: bold;
    text-align: center;
    padding: 0 20px;
  }
  .bodyCss{
    height: calc( 100% - 100px);
    padding: 0 20px;
    overflow-y: auto;
    .approveCss{
      position: relative;
      .approveTitleCss{
        color: #0099FF;
        font-weight: bold;
        font-size: 18px;
        padding-bottom: 14px;
        &:not(:first-child){
          margin-top: 30px;
        }
      }
      .companyInfoCss{
        background-color: #F6F8F9;
        padding: 20px;
        display: flex;
        flex-direction: column;
        row-gap: 20px;
        .companyInfoItemCss{
          text-align: left;
          display: flex;
        }
      }
      .certLabelCss{
        font-size: 14px;
        margin-bottom: 10px;
        &:not(:first-child){
          margin-top: 20px;
        }
      }
      .certImgCss{
        display: flex;
        column-gap: 20px;
        .certImgItemCss{
          height: 140px;
          width: 200px;
        }
      }
    }
  }
  .footerBtnCss{
    padding: 0 20px;
    padding-top: 14px;
    height: 50px;
    text-align: right;
  }
}
</style>
